<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var removeDuplicates = function (nums) {
        let n = nums.length;
        if (n < 2) {
          return n;
        }
        let fast = 0;
        let slow = 2;
        while (fast < n) {
          if (nums[slow - 2] != nums[fast]) {
            console.log(slow);
            nums[slow] = nums[fast];
            slow++;
          }
          fast++;
        }
        return slow;
      };

      console.log(removeDuplicates([1, 1, 1, 2, 2, 3]));
    </script>
  </body>
</html>
